home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Pascal Super Library
/
Pascal Super Library (CW International)(1997).bin
/
MATH
/
FPU
/
FPU.DOC
next >
Wrap
Text File
|
1991-12-22
|
2KB
|
44 lines
Although Turbo Pascal v6.0 can compile down to 80286/80287 instructions
creating more efficient code than the 8086/8088, 80387 instructions are out
of reach. The 80386 has just a few minor instruction additions over the
80286 with most of them only of concern to someone writing an operating
system. The 80287 isn't much different from the 8087. But the 80387 math
coprocessor fixes some shortcomings of the 80287 and adds a few new
instructions.
The 80287 places restrictions on the values passed to FATAN and FPTAN, but
the 80387 makes these instructions much simpler. The 80387 adds the
transendentals FSIN and FCOS. My time trials found that the following
pascal functions making direct calls to the 80387 executed about four times
faster than normal Pascal calls. I have a 25Mhz Cyrix FasMath Coprocessor,
so your results may differ if you have IIT or Intel coprocessors.
To use these functions, you can include them in your source code or make
a unit with them. To access them, globally replace function calls like
cos() to fcos(). Set your compiling options as follows: 286 instructions
on, 8087/80287 on, emulation off. I don't check if an 80387 is present,
so these functions work ONLY if used with an 80387 or 80486 DX and not on
the 8087/80287.
After testing FSQRT, I found it ran 18% SLOWER than letting Turbo Pascal
use sqrt(), so I didn't include it here. Using Turbo Debugger, I found
the coding for FSQRT contained lots of call overhead while sqrt() made the
call a lot more efficiently, so other functions like abs(), sqr() and int()
are not included.
I'm not an 80x86 assembly guru, but I know enough to be dangerous at this
point. I have tested these functions against normal Pascal functions, so
they work and return accurate results. I have found the floating-point
type "single" sufficient for my needs but you could replace "single" with
"double" or "extended" just the same; the compiler will handle the changes
in data sizes. These function calls are pretty simple and straight-forward
but if there's anything "dangerous" in the code, please let me know.
Erik Olbrys
December 1991
CIS 71236,1245
Explanations of the 387/386 opcodes adapted from:
Microsoft's 80386/80486 Programming Guide, 2nd ed. by Ross P. Nelson